package com.java.singleton;

/**
 * 没有线程安全问题
 * @author jingjintao
 * @date 2021/10/29 - 21:25
 **/
public class Singleton5 {

    private Singleton5(){

    }

    private static Singleton5 instance ;

    public static Singleton5 getInstance() throws InterruptedException {
        if(instance == null) {
            synchronized (Singleton5.class){
                if(instance == null){
                    Thread.sleep(1000);
                    instance = new Singleton5();
                }
            }
        }
        return instance;
    }
}
